<html>
<head>
<title>Google Earth API demo</title>
 <script src="http://maps.google.com/jsapi?key=ABQIAAAAO4IjyUfxvRPI0ZXJ51eyLhRLMv3CxaJ_YH4pfgTzrQFVSIqJ4BTIqdDNwBC8HoKfaEPq4_YIy66pNw"
    type="text/javascript">
  </script>

<script src="sos.js" type="text/javascript"></script>
<script src="intamap.js" type="text/javascript"></script>
<script>
google.load("earth", "1");
var ge = null;

function sosCallback(observations) {
    for(var i = 0; i < observations.getLength(); i++) {
        var o = observations.getObservation(i); 
        var placemark = ge.createPlacemark('');
        var point = ge.createPoint('');
        point.setLatitude(parseFloat(o.getLocation().getY()));
        point.setLongitude(parseFloat(o.getLocation().getX()));
        
        placemark.setName(o.getResult());
        placemark.setGeometry(point);
        ge.getFeatures().appendChild(placemark);
    }
}

function callSOS()
{
    var startdate = document.forms[0].startdate.value;
    var enddate = document.forms[0].enddate.value;
    var sos = new SOS("http://intamap.aston.ac.uk:8080/WeatherSOS/sos");
  sos.getObservations(sosCallback, 'WeatherUnderground','urn:x-ogc:def:phenomenon:OGC:Temperature','startdate','enddate','2009-03-23T00:00:00-0000' ); 
}

function init() {
  google.earth.createInstance("map3d", initCallback, failureCallback);
  
}

function initCallback(object) {
  ge = object;
  ge.getWindow().setVisibility(true);
}

function failureCallback(object) {
}
</script>

</head>
<body onload='init()' id='body'>
<div id='map3d_container'
           style='border: 1px solid silver; height: 600px; width: 800px;'>
        <div id='map3d' style='height: 100%;'></div>
      </div>
<FORM name="input" action="javascript:callSos()" method="post">
    Start Date: <input type="text" value="YYYY-MM-DDTHH:MM:SS" name="startdate"><BR>
    End Date:   <input type="text" value="YYYY-MM-DDTHH:MM:SS" name="enddate"><BR>
    Select a variable: <select name="variable">
                       <option value="solar radiation">Solar radiaton</option>
                       <option value="wind speed">Wind speed</option>
                       <option value="temperature">Temperature</option>
                       </select>
 <td colspan="2" align="center">
        <input type="submit" value="Submit">
 </td>
</FORM>
<a href="javascript:callSOS();">Load Observations</a>
</body>
</html>
